diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-14 05:28:01 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-14 05:28:01 +0000 |
| commit | 675b4e3d8ffcb57a041db285417d81e61284d900 (patch) | |
| tree | 254f3d6a6c0ce39ae8fba35618f3810e08945f19 /app/[lng]/partners | |
| parent | 39f12cb19f29cbc5568057e154e6adf4789ae736 (diff) | |
(대표님) RFQ-last, tbe-last, 기본계약 템플릿 내 견적,입찰,계약 추가, env.dev NAS_PATH 수정
Diffstat (limited to 'app/[lng]/partners')
| -rw-r--r-- | app/[lng]/partners/(partners)/rfq-last/[id]/page.tsx | 151 | ||||
| -rw-r--r-- | app/[lng]/partners/(partners)/rfq-last/page.tsx | 193 | ||||
| -rw-r--r-- | app/[lng]/partners/dtsocrshi/layout.tsx (renamed from app/[lng]/partners/ocr/layout.tsx) | 0 | ||||
| -rw-r--r-- | app/[lng]/partners/dtsocrshi/page.tsx (renamed from app/[lng]/partners/ocr/page.tsx) | 0 |
4 files changed, 344 insertions, 0 deletions
diff --git a/app/[lng]/partners/(partners)/rfq-last/[id]/page.tsx b/app/[lng]/partners/(partners)/rfq-last/[id]/page.tsx new file mode 100644 index 00000000..b14df5c3 --- /dev/null +++ b/app/[lng]/partners/(partners)/rfq-last/[id]/page.tsx @@ -0,0 +1,151 @@ +// app/partners/rfq-last/[id]/page.tsx +import { Metadata } from "next" +import { notFound } from "next/navigation" +import db from "@/db/db" +import { eq, and } from "drizzle-orm" +import { + rfqsLast, + rfqLastDetails, + rfqLastVendorResponses, + rfqPrItems,basicContractTemplates,basicContract, + vendors +} from "@/db/schema" +import { getServerSession } from "next-auth/next" +import { authOptions } from "@/app/api/auth/[...nextauth]/route" +import VendorResponseEditor from "@/lib/rfq-last/vendor-response/editor/vendor-response-editor" + +interface PageProps { + params: { + id: string + } +} + +export async function generateMetadata({ params }: PageProps): Promise<Metadata> { + return { + title: "견적서 작성", + description: "RFQ에 대한 견적서 작성 및 제출", + } +} + +export default async function VendorResponsePage({ params }: PageProps) { + const rfqId = parseInt(params.id) + + if (isNaN(rfqId)) { + notFound() + } + + // 인증 확인 + const session = await getServerSession(authOptions) + + if (!session?.user) { + return ( + <div className="flex h-full items-center justify-center"> + <div className="text-center"> + <h2 className="text-xl font-bold">로그인이 필요합니다</h2> + <p className="mt-2 text-muted-foreground">견적서 작성을 위해 로그인해주세요.</p> + </div> + </div> + ) + } + + // 벤더 정보 가져오기 + const vendor = await db.query.vendors.findFirst({ + where: eq(vendors.id, session.user.companyId) + }) + + if (!vendor || session.user.domain !== "partners") { + return ( + <div className="flex h-full items-center justify-center"> + <div className="text-center"> + <h2 className="text-xl font-bold">접근 권한이 없습니다</h2> + <p className="mt-2 text-muted-foreground">벤더 계정으로 로그인해주세요.</p> + </div> + </div> + ) + } + + // RFQ 정보 가져오기 + const rfq = await db.query.rfqsLast.findFirst({ + where: eq(rfqsLast.id, rfqId), + with: { + project: true, + rfqDetails: { + where: and(eq(rfqLastDetails.vendorsId, vendor.id),eq(rfqLastDetails.isLatest, true)), + with: { + vendor: true, + paymentTerms: true, + incoterms: true, + } + }, + rfqPrItems: true, + } + }) + + if (!rfq || !rfq.rfqDetails[0]) { + notFound() + } + + const rfqDetail = rfq.rfqDetails[0] + + // 기존 응답 가져오기 (있는 경우) + const existingResponse = await db.query.rfqLastVendorResponses.findFirst({ + where: and( + eq(rfqLastVendorResponses.rfqsLastId, rfqId), + eq(rfqLastVendorResponses.vendorId, vendor.id), + eq(rfqLastVendorResponses.isLatest, true) + ), + with: { + quotationItems: true, + attachments: true, + } + }) + + // PR Items 가져오기 + const prItems = await db.query.rfqPrItems.findMany({ + where: eq(rfqPrItems.rfqsLastId, rfqId), + orderBy: (items, { asc }) => [asc(items.rfqItem)] + }) + + const basicContracts = await db + .select({ + id: basicContract.id, + // templateId: basicContract.templateId, + templateName: basicContractTemplates.templateName, + status: basicContract.status, + // fileName: basicContract.fileName, + // filePath: basicContract.filePath, + deadline: basicContract.deadline, + signedAt: basicContract.vendorSignedAt, + // rejectedAt: basicContract.rejectedAt, + // rejectionReason: basicContract.rejectionReason, + createdAt: basicContract.createdAt, + }) + .from(basicContract) + .leftJoin( + basicContractTemplates, + eq(basicContract.templateId, basicContractTemplates.id) + ) + .where( + and( + eq(basicContract.vendorId, vendor.id), + eq(basicContract.rfqCompanyId, rfqDetail.id) + ) + ) + .orderBy(basicContract.createdAt) + + + return ( + <div className="container mx-auto py-8"> + <VendorResponseEditor + rfq={rfq} + rfqDetail={rfqDetail} + prItems={prItems} + vendor={vendor} + existingResponse={existingResponse} + userId={session.user.id} + basicContracts={basicContracts} // 추가 + + /> + </div> + ) +}
\ No newline at end of file diff --git a/app/[lng]/partners/(partners)/rfq-last/page.tsx b/app/[lng]/partners/(partners)/rfq-last/page.tsx new file mode 100644 index 00000000..cddb45dd --- /dev/null +++ b/app/[lng]/partners/(partners)/rfq-last/page.tsx @@ -0,0 +1,193 @@ +// app/vendor/quotations/page.tsx +import * as React from "react"; +import Link from "next/link"; +import { Metadata } from "next"; +import { getServerSession } from "next-auth/next"; +import { authOptions } from "@/app/api/auth/[...nextauth]/route"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Button } from "@/components/ui/button"; +import { LogIn } from "lucide-react"; +import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"; +import { Shell } from "@/components/shell"; +import { getValidFilters } from "@/lib/data-table"; +import { type SearchParams } from "@/types/table"; +import { searchParamsVendorRfqCache } from "@/lib/rfq-last/vendor-response/validations"; +import { InformationButton } from "@/components/information/information-button" +import { getVendorQuotationsLast,getQuotationStatusCountsLast } from "@/lib/rfq-last/vendor-response/service"; +import { VendorQuotationsTableLast } from "@/lib/rfq-last/vendor-response/vendor-quotations-table"; + +export const metadata: Metadata = { + title: "견적 목록", + description: "진행 중인 견적서 목록", +}; + +interface IndexPageProps { + searchParams: Promise<SearchParams> +} + + +export default async function IndexPage(props: IndexPageProps) { + const searchParams = await props.searchParams + const search = searchParamsVendorRfqCache.parse(searchParams) + const validFilters = getValidFilters(search.filters) + // 인증 확인 + const session = await getServerSession(authOptions); + + // 로그인 확인 + if (!session || !session.user) { + return ( + <Shell className="gap-6"> + <div className="flex items-center justify-between"> + <div> + <div className="flex items-center gap-2"> + <h2 className="text-2xl font-bold tracking-tight"> + 견적 목록 + </h2> + <InformationButton pagePath="partners/rfq-ship" /> + </div> + {/* <p className="text-muted-foreground"> + 진행 중인 견적서 목록을 확인하고 관리합니다. + </p> */} + </div> + </div> + + <div className="flex flex-col items-center justify-center py-12 text-center"> + <div className="rounded-lg border border-dashed p-10 shadow-sm"> + <h3 className="mb-2 text-xl font-semibold">로그인이 필요합니다</h3> + <p className="mb-6 text-muted-foreground"> + 견적서를 확인하려면 먼저 로그인하세요. + </p> + <Button size="lg" asChild> + <Link href="/partners?callbackUrl=/vendor/quotations"> + <LogIn className="mr-2 h-4 w-4" /> + 로그인하기 + </Link> + </Button> + </div> + </div> + </Shell> + ); + } + + // 벤더 ID 확인 + const vendorId = session.user.companyId ? String(session.user.companyId) : "0"; + + // 벤더 권한 확인 + if (session.user.domain !== "partners") { + return ( + <Shell className="gap-6"> + <div className="flex items-center justify-between"> + <div> + <h2 className="text-2xl font-bold tracking-tight"> + 접근 권한 없음 + </h2> + </div> + </div> + <div className="flex flex-col items-center justify-center py-12 text-center"> + <div className="rounded-lg border border-dashed p-10 shadow-sm"> + <h3 className="mb-2 text-xl font-semibold">벤더 계정이 필요합니다</h3> + <p className="mb-6 text-muted-foreground"> + 벤더 계정으로 로그인해주세요. + </p> + </div> + </div> + </Shell> + ); + } + + // 데이터 가져오기 + const quotationsPromise = getVendorQuotationsLast({ + ...search, + filters: validFilters + }, vendorId); + + // 상태별 개수 가져오기 + const statusCountsPromise = getQuotationStatusCountsLast(vendorId); + + // 모든 프로미스 병렬 실행 + const promises = Promise.all([quotationsPromise]); + const statusCounts = await statusCountsPromise; + + return ( + <Shell className="gap-6"> + <div className="flex justify-between items-center"> + <div> + <h2 className="text-2xl font-bold tracking-tight">견적 목록</h2> + <p className="text-muted-foreground"> + 진행 중인 견적서 목록을 확인하고 관리합니다. + </p> + </div> + </div> + + <div className="grid gap-4 md:grid-cols-5"> + <Card> + <CardHeader className="py-4"> + <CardTitle className="text-base">전체 견적</CardTitle> + </CardHeader> + <CardContent> + <div className="text-2xl font-bold"> + {Object.values(statusCounts).reduce((sum, count) => sum + count, 0)}건 + </div> + </CardContent> + </Card> + + <Card> + <CardHeader className="py-4"> + <CardTitle className="text-base">응답 대기</CardTitle> + </CardHeader> + <CardContent> + <div className="text-2xl font-bold text-orange-600"> + {statusCounts["미응답"] || 0}건 + </div> + </CardContent> + </Card> + + <Card> + <CardHeader className="py-4"> + <CardTitle className="text-base">작성 중</CardTitle> + </CardHeader> + <CardContent> + <div className="text-2xl font-bold text-blue-600"> + {statusCounts["작성중"] || 0}건 + </div> + </CardContent> + </Card> + + <Card> + <CardHeader className="py-4"> + <CardTitle className="text-base">제출 완료</CardTitle> + </CardHeader> + <CardContent> + <div className="text-2xl font-bold text-green-600"> + {(statusCounts["제출완료"] || 0) + (statusCounts["최종확정"] || 0)}건 + </div> + </CardContent> + </Card> + + <Card> + <CardHeader className="py-4"> + <CardTitle className="text-base">불참</CardTitle> + </CardHeader> + <CardContent> + <div className="text-2xl font-bold text-gray-500"> + {statusCounts["불참"] || 0}건 + </div> + </CardContent> + </Card> + </div> + + <React.Suspense + fallback={ + <DataTableSkeleton + columnCount={7} + searchableColumnCount={2} + filterableColumnCount={3} + cellWidths={["10rem", "10rem", "8rem", "10rem", "10rem", "10rem", "8rem"]} + /> + } + > + <VendorQuotationsTableLast promises={promises} /> + </React.Suspense> + </Shell> + ); +}
\ No newline at end of file diff --git a/app/[lng]/partners/ocr/layout.tsx b/app/[lng]/partners/dtsocrshi/layout.tsx index f1654bf2..f1654bf2 100644 --- a/app/[lng]/partners/ocr/layout.tsx +++ b/app/[lng]/partners/dtsocrshi/layout.tsx diff --git a/app/[lng]/partners/ocr/page.tsx b/app/[lng]/partners/dtsocrshi/page.tsx index 7a12b75d..7a12b75d 100644 --- a/app/[lng]/partners/ocr/page.tsx +++ b/app/[lng]/partners/dtsocrshi/page.tsx |
